

<template>
  <div  class="right_div">
            <div >
              <ul>
                <li
                  v-for="(item, index) in tagsList"
                  :key="index"
                  @click="handleTagsSelect(item)"
                >
                  {{ item.name }}
                </li>
              </ul>
            </div>
    </div>
</template>
<script setup lang="ts">
const emit = defineEmits(['getTemplateListByCate']);

defineProps<{
  tagsList: Array<{
    id: string;
    name: string;
  }>;
}>();
const currentTagId = ref<string>(''); // 选中的标签
const currentTagName = ref<string>(''); // 选中的标签
// 点击标签
const handleTagsSelect = (item: any) => {

  if (currentTagId.value === item.id) {
    currentTagId.value = '';
    currentTagName.value = '';
  } else {
    currentTagId.value = item.id;
    currentTagName.value = item.name;
  }
  let queryParams = {
    tagId: currentTagId.value
  };
  emit('getTemplateListByCate', queryParams);
};

</script>
<style scoped lang="scss">
.right_div {
  float: right;
  position:relative;
  z-index:999;
  top:0;
}
.parent{
  position: relative;
}
.block{
  position: absolute;
  right: 0;
}
</style>